package demo02;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class demo2 {
    public static void main(String[] args) {
//        方法一：
        int[] array1 = {1,2,3,4};
        System.out.println("array1:"+ Arrays.toString(array1));
//        方法二：
        int[] array2 = new int[]{1,2,3,4};
        System.out.println("array2:"+Arrays.toString(array2));
//        方法三：
        int[] array3 = new int[4];
        for (int i = 0; i < 4; i++) {
            array3[i] = i;
        }
        System.out.println("array3:"+Arrays.toString(array3));
        System.out.println(array3.length);
//        方法四
        ArrayList<Integer> arrayList = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            arrayList.add(i);
        }
        System.out.println("arrayList:"+arrayList.toString());
        arrayList.get(0);
        arrayList.set(1,9);
        arrayList.remove(3);
        arrayList.size();
        arrayList.contains(2);

//        数组排序
        int[] array4 = {22,11,2,35,6,1,10};
        Arrays.sort(array4);
        Collections.sort(arrayList);

     }
}
